package com.yanjr.modules.sys.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.yanjr.common.Constants;
import com.yanjr.common.persistence.BaseDaoImpl;
import com.yanjr.modules.sys.dao.AreaDao;
import com.yanjr.modules.sys.entity.Area;

@Repository("areaDao")
public class AreaDaoImpl extends BaseDaoImpl<Area> implements AreaDao {

	@Override
	public List<Area> findByParentIdsLike(String parentIds) {
		String sql = "select * from sys_area where parent_ids like ?";
		return super.findList(sql, new Object[] {parentIds});
	}

	@Override
	public List<Area> findAllList() {
		String sql = "select * from sys_area where del_flag= ? order by code";
		return super.findList(sql, new Object[] {Constants.DEL_FLAG_NORMAL});
	}

	@Override
	public List<Area> findAllChild(Long parentId, String likeParentIds) {
		String sql = "select * from sys_area where del_flag=? and (id=? or parent_id=? or parent_ids=?) order by code";
		return super.findList(sql, new Object[] {Constants.DEL_FLAG_NORMAL, parentId, parentId, likeParentIds});
	}

	

}
